<template>
  <div class="new-pagenav">
    <div class="new-pagenav-left">
      <a class="new-prepage" href="#" @click="calculate('left')">
        <span v-if="query.current != 1">&#60;</span>
      </a>
    </div>
    <div class="new-pagenav-center">
      <span class="iconfont">&#9749;</span>
      <span class="new-nowpage">第{{ query.current }}页</span>
    </div>
    <div class="new-pagenav-right">
      <a class="new-nextpage" href="#" @click="calculate('right')">
        <span v-if="query.pages > 1 && query.current != query.pages">&#62;</span>
      </a>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MobilePagination',
  props: {
    query: {
      type: Object,
      default: function () {
        return {
          current: 1,
          size: 10,
          total: 20,
          pages: 3
        }
      }
    }
  },
  data () {
    return {}
  },
  methods: {
    calculate (value) {
      this.query.current += value === 'left' ? -1 : 1
      this.$emit('page', this.query)
    }
  }
}
</script>

<style lang="stylus" scoped>
  a
    color: #999

  .new-pagenav
    display flex
    justify-content space-between
    line-height: 42px
    width auto
    .new-pagenav-left
      width: 40%
      white-space: nowrap
      -webkit-box-flex: 1
      -webkit-flex: 1 1 auto
      .new-prepage
        display block
        text-align right
        span
          margin-right: 32%
    .new-pagenav-center
      -webkit-box-flex: 0
      -webkit-flex: none
      .iconfont
        font-size: 14px
      .new-nowpage
        position relative
        line-height 42px
        margin .08rem 0
        background: #fff
        color: #606266
        font-size: 14px
    .new-pagenav-right
      width: 40%
      white-space: nowrap
      -webkit-box-flex: 1
      -webkit-flex: 1 1 auto
      .new-nextpage
        display: block
        text-align: left
        span
          margin-left: 32%
</style>
